/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clockanimationusingthread;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;

/**
 *
 * @author chris
 */
public class Clock extends ClockAnimationUsingThread {

    private boolean suspended;

    public void suspend() {
        suspended = true;
    }

    public void resume() {
        suspended = false;
    }

    @Override
    public void run() {
        while (true) {
            if (!suspended) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        setCurrentTime();
                        repaint();
                    }
                });
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
}
